package com.原型模式.深拷贝;

/**
 * @author Fang Ruichuan
 * @date 2022-09-22 10:22
 */

public class Client {
    public static void main(String[] args) throws CloneNotSupportedException {
        DeepProtoType p = new DeepProtoType();
        p.name = "宋江";
        p.deepCloneableTarget = new DeepCloneableTarget("大牛", "小牛的");
        // 方式一：完成深拷贝
        DeepProtoType p2 = (DeepProtoType) p.clone();
        System.out.println("p.name = " + p.name + "p.deepCloneableTarget = " + p.deepCloneableTarget.hashCode());
        System.out.println("p2.name = " + p2.name + "p2.deepCloneableTarget = " + p2.deepCloneableTarget.hashCode());
    }
}
